<?php $this->load->view('common/head');?>

<?php $this->load->view('common/header');?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar');?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs');?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set');?>

                <!-- /section:settings.box -->
                <div class="row">
                    <form class="form-inline" action="<?php echo site_url(X_URL.'article/index')?>" method="get" id="form2">
                        <label class="inline">资讯搜索</label>
                        <select name="field" class="form-control">
                            <option value="article_title">标题</option>
                        </select>
                        <input type="text" name="title" value="" class="form-control" id="title">
                        <label class="inline">&nbsp;&nbsp;分类：</label>
                        <select id="article_category" name="article_category" class="select2">
                            <option value="0">请选择分类</option>
                            <?php if(isset($category) && !empty($category)){ ?>
                                <?php foreach ($category as $key =>$val ) { ?>
                                    <option value="<?php echo $val['id'];?>" <?php if(isset($article) && $article['article_category'] == $val['id']){?>selected="selected"<?php } ?>
                                    ><?php echo $val['category_name'];?></option>
                                <?php }?>
                            <?php }?>
                        </select>
                        <button type="submit" class="btn btn-purple btn-sm" id="submit">
                            <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                            查询
                        </button>
                        <span class="btn btn-purple btn-sm" id="addarticle">
                            <span class="ace-icon fa fa-user icon-on-right bigger-110"></span>
                            新增单页
                        </span>
                    </form>

                    <div class="col-xs-12">

                        </div>
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th class="center"><input class="check-all" type="checkbox" value=""></th>
                                <th>文章标题</th>
                                <th>所属分类</th>
                                <th class="center">文章概述</th>
                                <th class="center">添加时间</th>
                                <th class="">排序</th>
                                <th class="center">操作</th>
                            </tr>
                            </thead>
                            <tbody>

                            <?php if($articles){ foreach ($articles as $key => $val) { ?>
                                <tr>
                                    <td class="center">
                                        <input class="uids" type="checkbox" name="gids[]" >
                                    </td>
                                    <td><?php echo $val['article_title']; ?></td>
                                    <td class="grouptd">
                                        <span class="label label-sm label-info arrowed arrowed-righ"><?php echo $val['category_name']; ?></span>
                                    </td>
                                    <td class="center"><?php echo $val['article_memo']; ?></td>
                                    <td><?php echo date("Y-m-d H:i:s",$val['article_add_time']); ?></td>
                                    <td>
                                        <input name="order" class="inputorder" type="number" value="<?php echo $val['order'];?>"
                                               val="<?php echo $val['article_id'];?>"/>
                                    </td>
                                    <td class="center">
                                        <a href="<?php echo site_url(X_URL.'article/edit/'.$val['article_id']);?>">修改</a>&nbsp;
                                        <a class="red del" href="javascript:;" val="<?php echo site_url(X_URL.'article/del/'.$val['article_id']);?>" title="删除">删除</a>
                                    </td>
                                </tr>
                            <?php } ?>
                            <?php }?>
                            </tbody>
                        </table>
                        <?php if($pagination){?><ul class="pagination"><?php echo $pagination;?></ul><?php }?>
<!--                        {$page}-->
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
    </div><!-- /.main-content -->

<?php $this->load->view('common/footer');?>
</div><!-- /.main-container -->

<?php $this->load->view('common/footerjs');?>
<!-- inline scripts related to this page -->
<script type="text/javascript">

    $(function () {
        $("#officialnews ul").html('<div class="ace-icon fa fa-spinner fa-spin orange"></div>');

        $(".inputorder").change(function () {
            var id = $(this).attr('val');
            var o = $(this).val();
            $.post(baseurl+'index.php/manage/article/update', {id: id, o: o,'csrf_test_name': ci_csrf_token(),'only_o':1}, function (data) {
                    if (data == 1) {
                        window.location.reload(true);
                    }
                }
            );
        })
    })
    $("#addarticle").click(function () {
        window.location.href="add";
    });
    $(".del").click(function () {
            var url = $(this).attr('val');
            bootbox.confirm({
                title: "系统提示",
                message: "确定要删除?",
                callback: function (result) {
                    if (result) {
                        window.location.href = url;
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });

</script>
</body>
</html>
